import { IFeidaoAiNodejsPage } from '@feidao/web/interfaces';

import { generate } from '@feidao/core/querystring';
import check_user from '@feidao/web/atom/nodejs/authorization/check';
import is_online from '@feidao/web/atom/nodejs/msg/user-isonline';
import set_code from '@feidao/web/atom/nodejs/server/status-code';

import return_fail from '@feidao/web/atom/nodejs/server/return-fail';
import redirect from '@feidao/web/atom/nodejs/server/redirect';
import obj_mixin from '@feidao/web/atom/core/obj/mixin';


function set_url(feidao_data: IFeidaoAiNodejsPage) {
	const obj = {
		backurl: feidao_data.data.url
	};
	return generate(obj, 'login.html');
}

export default async function check(feidao_data: IFeidaoAiNodejsPage) {
	const line = await is_online();
	if (line) {

	} else {
		const url = set_url(feidao_data);
		const r = redirect(url);
		return return_fail(r);
	}
}